package com.heying.springcore.xml;

import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * IoC:  Inversion of Control 控制反转
 * 对象的控制权由程序员自己反转到容器
 * DI Dependence Injection 依赖注入
 * 依赖关系是由容器帮你注入进去的
 */
public class Story {
    public static void main(String[] args) {
        //加载classpath下的配置文件，加载ioc容器。创建好beanfactory
        ClassPathXmlApplicationContext context =
               new ClassPathXmlApplicationContext("applicationContext.xml");
        Car car = context.getBean("car",Car.class);
        System.out.println(car);

//        Tank tank = context.getBean("tank",Tank.class);
//        System.out.println(tank);

        Driver driver= context.getBean("driver",Driver.class);
        driver.drive();

    }
}
